package com.aaa.ssm.controller;

import com.aaa.ssm.entity.Subscribe;
import com.aaa.ssm.service.SubscribeService;
import com.aaa.ssm.util.Page;
import com.aaa.ssm.util.Result;
import com.github.pagehelper.PageInfo;

import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @author wjz
 * 2023/10/13
 */
@RestController
@RequestMapping("/subscribe")
public class SubscribeController {

    @Resource
    private SubscribeService subscribeService;


    /**
     * @param subscribe
     * @return 添加
     */
    @PostMapping
    public Result<?> save(@RequestBody Subscribe subscribe) {

        return Result.success(subscribeService.add(subscribe));
    }

    /**
     * @param subscribe
     * @return  前台挂号添加
     */
    @PostMapping("/add")
    public Result<?> insert(@RequestBody Subscribe subscribe) {


        return Result.success(subscribeService.add(subscribe));
    }


    @GetMapping
    public Result<?> queryByParam(Page<Subscribe> page) {
        PageInfo pageInfo=subscribeService.queryByParam(page);
        return Result.success(pageInfo);
    }

    //id 查询
    @GetMapping("/{id}")
    public Result<?> selectById(@PathVariable Integer id) {

        return Result.success(subscribeService.selectById(id));
    }

//    @GetMapping("/select")
//    public Result<?> select(Subscribe subscribe) {
//
//        List<Subscribe> subscribes = subscribeService.selectById(subscribe);
//        return Result.success(subscribes);
//    }


    @GetMapping("sub")
    public Result<?> sub(String careerId, String date) {
        System.out.println(".............."+careerId+"..............."+date);
        Subscribe subscribe = subscribeService.querySchedulingInfo(careerId,date);

        return Result.success(subscribe);


    }


}
